﻿$(function() {

    window.setTimeout(function() {
    
        $('#sku-select .Cor label').each(function() {
        
            var colorNameOriginal = $(this).text();
            var colorName = $(this).text();
            colorName = colorName.toLowerCase();
            colorName = colorName.replace(new RegExp('[áàâã]','gi'), 'a');
            colorName = colorName.replace(new RegExp('[éèê]','gi'), 'e');
            colorName = colorName.replace(new RegExp('[íìî]','gi'), 'i');
            colorName = colorName.replace(new RegExp('[óòôõ]','gi'), 'o');
            colorName = colorName.replace(new RegExp('[úùû]','gi'), 'u');
            colorName = colorName.replace(new RegExp('[ç]','gi'), 'c');
            colorName = colorName.replace(new RegExp('[\ \)\(\_]', 'gi'), '-');
            colorName = colorName.replace(new RegExp('[^a-z0-9\-]', 'gi'), '');
            
            $(this).css( 'background' , 'url(/arquivos/corprod_' + colorName + '.png) 0 0 no-repeat' ).attr( 'title' , colorNameOriginal );
        
        });
    
    },2000);
    
    $('#sku-select').mouseup(function(){
        window.setTimeout(function(){
            $('#sku-select label').removeClass('sku-picked');
            $('#sku-select input:checked').next().addClass('sku-picked');
        },600);
    });
    
});